<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>PCL中深度图像相关算法 | 荒岛</title><meta name="author" content="Fi9zero"><meta name="copyright" content="Fi9zero"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="深度图像深度图像（Depth Images）也被称为距离图像（Range Image），是指将从图像采集器到场景中各点的距离值作为像素值的图像，它直接反应了景物可见表面的几何形状，利用它可以很方便的解决3D目标描述中的许多问题，深度图像经过点云变换可以计算为点云数据，点云数据可以反算为深度图像数据。 从一个点云生成深度图像这段代码一直运行报错，目前还没有跑通 1234567891011121314">
<meta property="og:type" content="article">
<meta property="og:title" content="PCL中深度图像相关算法">
<meta property="og:url" content="https://ckyfi9zero.github.io/2025/08/02/2025-08-02-PCL%E4%B8%AD%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F%E7%9B%B8%E5%85%B3%E7%AE%97%E6%B3%95/index.html">
<meta property="og:site_name" content="荒岛">
<meta property="og:description" content="深度图像深度图像（Depth Images）也被称为距离图像（Range Image），是指将从图像采集器到场景中各点的距离值作为像素值的图像，它直接反应了景物可见表面的几何形状，利用它可以很方便的解决3D目标描述中的许多问题，深度图像经过点云变换可以计算为点云数据，点云数据可以反算为深度图像数据。 从一个点云生成深度图像这段代码一直运行报错，目前还没有跑通 1234567891011121314">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://ckyfi9zero.github.io/image/avatar.jpg">
<meta property="article:published_time" content="2025-08-02T03:04:57.000Z">
<meta property="article:modified_time" content="2025-08-02T03:30:55.592Z">
<meta property="article:author" content="Fi9zero">
<meta property="article:tag" content="c++">
<meta property="article:tag" content="PCL">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://ckyfi9zero.github.io/image/avatar.jpg"><script type="application/ld+json">{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "PCL中深度图像相关算法",
  "url": "https://ckyfi9zero.github.io/2025/08/02/2025-08-02-PCL%E4%B8%AD%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F%E7%9B%B8%E5%85%B3%E7%AE%97%E6%B3%95/",
  "image": "https://ckyfi9zero.github.io/image/avatar.jpg",
  "datePublished": "2025-08-02T03:04:57.000Z",
  "dateModified": "2025-08-02T03:30:55.592Z",
  "author": [
    {
      "@type": "Person",
      "name": "Fi9zero",
      "url": "https://ckyfi9zero.github.io"
    }
  ]
}</script><link rel="shortcut icon" href="/image/favicon.ico"><link rel="canonical" href="https://ckyfi9zero.github.io/2025/08/02/2025-08-02-PCL%E4%B8%AD%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F%E7%9B%B8%E5%85%B3%E7%AE%97%E6%B3%95/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><script>
    (() => {
      
    const saveToLocal = {
      set: (key, value, ttl) => {
        if (!ttl) return
        const expiry = Date.now() + ttl * 86400000
        localStorage.setItem(key, JSON.stringify({ value, expiry }))
      },
      get: key => {
        const itemStr = localStorage.getItem(key)
        if (!itemStr) return undefined
        const { value, expiry } = JSON.parse(itemStr)
        if (Date.now() > expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return value
      }
    }

    window.btf = {
      saveToLocal,
      getScript: (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        Object.entries(attr).forEach(([key, val]) => script.setAttribute(key, val))
        script.onload = script.onreadystatechange = () => {
          if (!script.readyState || /loaded|complete/.test(script.readyState)) resolve()
        }
        script.onerror = reject
        document.head.appendChild(script)
      }),
      getCSS: (url, id) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onload = link.onreadystatechange = () => {
          if (!link.readyState || /loaded|complete/.test(link.readyState)) resolve()
        }
        link.onerror = reject
        document.head.appendChild(link)
      }),
      addGlobalFn: (key, fn, name = false, parent = window) => {
        if (!false && key.startsWith('pjax')) return
        const globalFn = parent.globalFn || {}
        globalFn[key] = globalFn[key] || {}
        globalFn[key][name || Object.keys(globalFn[key]).length] = fn
        parent.globalFn = globalFn
      }
    }
  
      
      const activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      const activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }

      btf.activateDarkMode = activateDarkMode
      btf.activateLightMode = activateLightMode

      const theme = saveToLocal.get('theme')
    
          theme === 'dark' ? activateDarkMode() : theme === 'light' ? activateLightMode() : null
        
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        document.documentElement.classList.toggle('hide-aside', asideStatus === 'hide')
      }
    
      
    const detectApple = () => {
      if (/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)) {
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
  
    })()
  </script><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"未找到符合您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false,"highlightFullpage":false,"highlightMacStyle":true},
  copy: {
    success: '复制成功',
    error: '复制失败',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'null',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyloadPlugin: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'PCL中深度图像相关算法',
  isHighlightShrink: false,
  isToc: true,
  pageType: 'post'
}</script><link rel="stylesheet" href="/css/custom.css"><link rel="stylesheet" href="/css/pig.css"><link rel="stylesheet" href="https://npm.elemecdn.com/ethan4116-blog/lib/css/plane_v2.css"><meta name="generator" content="Hexo 7.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img text-center"><img src="/image/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data text-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/booklist/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(/image/per%20page.jpg);"><nav id="nav"><span id="blog-info"><a class="nav-site-title" href="/"><span class="site-name">荒岛</span></a><a class="nav-page-title" href="/"><span class="site-name">PCL中深度图像相关算法</span><span class="site-name"><i class="fa-solid fa-circle-arrow-left"></i><span>  返回首页</span></span></a></span><div id="menus"><div id="search-button"><span class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></span></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/booklist/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><span class="site-page"><i class="fas fa-bars fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">PCL中深度图像相关算法</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2025-08-02T03:04:57.000Z" title="发表于 2025-08-02 11:04:57">2025-08-02</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2025-08-02T03:30:55.592Z" title="更新于 2025-08-02 11:30:55">2025-08-02</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/PCL/">PCL</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">浏览量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="container post-content" id="article-container"><h1 id="深度图像"><a href="#深度图像" class="headerlink" title="深度图像"></a>深度图像</h1><p>深度图像（Depth Images）也被称为距离图像（Range Image），是指将从图像采集器到场景中各点的距离值作为像素值的图像，它直接反应了景物可见表面的几何形状，利用它可以很方便的解决3D目标描述中的许多问题，深度图像经过点云变换可以计算为点云数据，点云数据可以反算为深度图像数据。</p>
<h2 id="从一个点云生成深度图像"><a href="#从一个点云生成深度图像" class="headerlink" title="从一个点云生成深度图像"></a>从一个点云生成深度图像</h2><p><strong>这段代码一直运行报错，目前还没有跑通</strong></p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/range_image/range_image.h&gt;</span>   <span class="comment">// 引入 PCL 深度图像相关头文件</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span> <span class="params">(<span class="type">int</span> argc, <span class="type">char</span>** argv)</span> </span>&#123;</span><br><span class="line">  pcl::PointCloud&lt;pcl::PointXYZ&gt; pointCloud;   <span class="comment">// 创建 XYZ 点云对象</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// 生成数据：在 y-z 平面上每隔 1 cm 采样，x 固定为 2 - y</span></span><br><span class="line">  <span class="keyword">for</span> (<span class="type">float</span> y = <span class="number">-0.5f</span>; y &lt;= <span class="number">0.5f</span>; y += <span class="number">0.01f</span>) &#123;</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">float</span> z = <span class="number">-0.5f</span>; z &lt;= <span class="number">0.5f</span>; z += <span class="number">0.01f</span>) &#123;</span><br><span class="line">      pcl::PointXYZ point;           <span class="comment">// 创建一个点</span></span><br><span class="line">      point.x = <span class="number">2.0f</span> - y;            <span class="comment">// x = 2 - y</span></span><br><span class="line">      point.y = y;                   <span class="comment">// y 保持不变</span></span><br><span class="line">      point.z = z;                   <span class="comment">// z 保持不变</span></span><br><span class="line">      pointCloud.points.<span class="built_in">push_back</span>(point); <span class="comment">// 加入点云</span></span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 设置点云宽度和高度（无组织点云 height = 1）</span></span><br><span class="line">  pointCloud.width  = (<span class="type">uint32_t</span>) pointCloud.points.<span class="built_in">size</span>();</span><br><span class="line">  pointCloud.height = <span class="number">1</span>;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// ----------- 以下参数用于生成深度图 -----------</span></span><br><span class="line">  <span class="type">float</span> angularResolution = (<span class="type">float</span>) (<span class="number">1.0f</span> * (M_PI/<span class="number">180.0f</span>));   <span class="comment">// 角分辨率：1° → 弧度</span></span><br><span class="line">  <span class="type">float</span> maxAngleWidth     = (<span class="type">float</span>) (<span class="number">360.0f</span> * (M_PI/<span class="number">180.0f</span>)); <span class="comment">// 水平视野：360° → 弧度</span></span><br><span class="line">  <span class="type">float</span> maxAngleHeight    = (<span class="type">float</span>) (<span class="number">180.0f</span> * (M_PI/<span class="number">180.0f</span>)); <span class="comment">// 垂直视野：180° → 弧度</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// 传感器位姿：原点，无旋转</span></span><br><span class="line">  Eigen::Affine3f sensorPose = (Eigen::Affine3f)Eigen::<span class="built_in">Translation3f</span>(<span class="number">0.0f</span>, <span class="number">0.0f</span>, <span class="number">0.0f</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 坐标系：以相机坐标系为准</span></span><br><span class="line">  pcl::RangeImage::CoordinateFrame coordinate_frame = pcl::RangeImage::CAMERA_FRAME;</span><br><span class="line"></span><br><span class="line">  <span class="type">float</span> noiseLevel = <span class="number">0.00</span>;   <span class="comment">// 无噪声</span></span><br><span class="line">  <span class="type">float</span> minRange   = <span class="number">0.0f</span>;   <span class="comment">// 最小测距 0</span></span><br><span class="line">  <span class="type">int</span>   borderSize = <span class="number">1</span>;      <span class="comment">// 边界像素 1</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// 创建并生成深度图像</span></span><br><span class="line">  pcl::RangeImage rangeImage;</span><br><span class="line">  rangeImage.<span class="built_in">createFromPointCloud</span>(pointCloud,</span><br><span class="line">                                  angularResolution, maxAngleWidth, maxAngleHeight,</span><br><span class="line">                                  sensorPose, coordinate_frame,</span><br><span class="line">                                  noiseLevel, minRange, borderSize);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 终端输出：深度图像信息</span></span><br><span class="line">  std::cout &lt;&lt; <span class="string">&quot;生成的深度图像：\n&quot;</span> &lt;&lt; rangeImage &lt;&lt; <span class="string">&quot;\n&quot;</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="从深度图像中提取边界"><a href="#从深度图像中提取边界" class="headerlink" title="从深度图像中提取边界"></a>从深度图像中提取边界</h2><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;iostream&gt;</span>                                <span class="comment">// 标准输入输出</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;boost/thread/thread.hpp&gt;</span>                 <span class="comment">// Boost 线程，用于 spinOnce</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/range_image/range_image.h&gt;</span>           <span class="comment">// 深度图像类</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/io/pcd_io.h&gt;</span>                         <span class="comment">// PCD 文件读写</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/visualization/range_image_visualizer.h&gt;</span> <span class="comment">// 深度图像可视化</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/visualization/pcl_visualizer.h&gt;</span>      <span class="comment">// 3D 可视化</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/features/range_image_border_extractor.h&gt;</span> <span class="comment">// 边界提取器</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/console/parse.h&gt;</span>                     <span class="comment">// 命令行解析</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> pcl::PointXYZ PointType;                   <span class="comment">// 简写别名</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// --------------------</span></span><br><span class="line"><span class="comment">// -----参数-----</span></span><br><span class="line"><span class="comment">// --------------------</span></span><br><span class="line"><span class="type">float</span> angular_resolution = <span class="number">0.5f</span>;                   <span class="comment">// 默认角分辨率 0.5°</span></span><br><span class="line">pcl::RangeImage::CoordinateFrame coordinate_frame = pcl::RangeImage::CAMERA_FRAME;</span><br><span class="line"><span class="type">bool</span> setUnseenToMaxRange = <span class="literal">false</span>;                  <span class="comment">// 是否把不可见点设成最大距离</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// --------------</span></span><br><span class="line"><span class="comment">// -----帮助-----</span></span><br><span class="line"><span class="comment">// --------------</span></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">printUsage</span><span class="params">(<span class="type">const</span> <span class="type">char</span>* progName)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  std::cout &lt;&lt; <span class="string">&quot;\n\n用法: &quot;</span> &lt;&lt; progName &lt;&lt; <span class="string">&quot; [选项] &lt;scene.pcd&gt;\n\n&quot;</span></span><br><span class="line">            &lt;&lt; <span class="string">&quot;选项:\n&quot;</span></span><br><span class="line">            &lt;&lt; <span class="string">&quot;-------------------------------------------\n&quot;</span></span><br><span class="line">            &lt;&lt; <span class="string">&quot;-r &lt;float&gt;   角分辨率(度) (默认 &quot;</span> &lt;&lt; angular_resolution &lt;&lt; <span class="string">&quot;)\n&quot;</span></span><br><span class="line">            &lt;&lt; <span class="string">&quot;-c &lt;int&gt;     坐标系 (默认 &quot;</span> &lt;&lt; (<span class="type">int</span>)coordinate_frame &lt;&lt; <span class="string">&quot;)\n&quot;</span></span><br><span class="line">            &lt;&lt; <span class="string">&quot;-m           将所有不可见点设为最大距离\n&quot;</span></span><br><span class="line">            &lt;&lt; <span class="string">&quot;-h           显示本帮助\n&quot;</span></span><br><span class="line">            &lt;&lt; <span class="string">&quot;\n\n&quot;</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// --------------</span></span><br><span class="line"><span class="comment">// -----主函数-----</span></span><br><span class="line"><span class="comment">// --------------</span></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">(<span class="type">int</span> argc, <span class="type">char</span>** argv)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  <span class="comment">// --------------------------------------</span></span><br><span class="line">  <span class="comment">// -----解析命令行参数-----</span></span><br><span class="line">  <span class="comment">// --------------------------------------</span></span><br><span class="line">  <span class="keyword">if</span> (pcl::console::<span class="built_in">find_argument</span>(argc, argv, <span class="string">&quot;-h&quot;</span>) &gt;= <span class="number">0</span>)</span><br><span class="line">  &#123;</span><br><span class="line">    <span class="built_in">printUsage</span>(argv[<span class="number">0</span>]);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> (pcl::console::<span class="built_in">find_argument</span>(argc, argv, <span class="string">&quot;-m&quot;</span>) &gt;= <span class="number">0</span>)</span><br><span class="line">  &#123;</span><br><span class="line">    setUnseenToMaxRange = <span class="literal">true</span>;</span><br><span class="line">    std::cout &lt;&lt; <span class="string">&quot;将深度图像中所有不可见值设为最大距离。\n&quot;</span>;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="type">int</span> tmp_coordinate_frame;</span><br><span class="line">  <span class="keyword">if</span> (pcl::console::<span class="built_in">parse</span>(argc, argv, <span class="string">&quot;-c&quot;</span>, tmp_coordinate_frame) &gt;= <span class="number">0</span>)</span><br><span class="line">  &#123;</span><br><span class="line">    coordinate_frame = pcl::RangeImage::<span class="built_in">CoordinateFrame</span>(tmp_coordinate_frame);</span><br><span class="line">    std::cout &lt;&lt; <span class="string">&quot;使用坐标系 &quot;</span> &lt;&lt; (<span class="type">int</span>)coordinate_frame &lt;&lt; <span class="string">&quot;。\n&quot;</span>;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> (pcl::console::<span class="built_in">parse</span>(argc, argv, <span class="string">&quot;-r&quot;</span>, angular_resolution) &gt;= <span class="number">0</span>)</span><br><span class="line">    std::cout &lt;&lt; <span class="string">&quot;设置角分辨率为 &quot;</span> &lt;&lt; angular_resolution &lt;&lt; <span class="string">&quot; 度。\n&quot;</span>;</span><br><span class="line">  angular_resolution = pcl::<span class="built_in">deg2rad</span>(angular_resolution);   <span class="comment">// 角度转弧度</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// ------------------------------------------------------------------</span></span><br><span class="line">  <span class="comment">// -----读取PCD文件；如未提供则生成示例点云-----</span></span><br><span class="line">  <span class="comment">// ------------------------------------------------------------------</span></span><br><span class="line">  pcl::PointCloud&lt;PointType&gt;::<span class="function">Ptr <span class="title">point_cloud_ptr</span><span class="params">(<span class="keyword">new</span> pcl::PointCloud&lt;PointType&gt;)</span></span>;</span><br><span class="line">  pcl::PointCloud&lt;PointType&gt;&amp; point_cloud = *point_cloud_ptr;</span><br><span class="line">  pcl::PointCloud&lt;pcl::PointWithViewpoint&gt; far_ranges;</span><br><span class="line">  <span class="function">Eigen::Affine3f <span class="title">scene_sensor_pose</span><span class="params">(Eigen::Affine3f::Identity())</span></span>;</span><br><span class="line"></span><br><span class="line">  std::vector&lt;<span class="type">int</span>&gt; pcd_filename_indices =</span><br><span class="line">      pcl::console::<span class="built_in">parse_file_extension_argument</span>(argc, argv, <span class="string">&quot;pcd&quot;</span>);</span><br><span class="line">  <span class="keyword">if</span> (!pcd_filename_indices.<span class="built_in">empty</span>())</span><br><span class="line">  &#123;</span><br><span class="line">    std::string filename = argv[pcd_filename_indices[<span class="number">0</span>]];</span><br><span class="line">    <span class="keyword">if</span> (pcl::io::<span class="built_in">loadPCDFile</span>(filename, point_cloud) == <span class="number">-1</span>)</span><br><span class="line">    &#123;</span><br><span class="line">      std::cout &lt;&lt; <span class="string">&quot;无法打开文件 \&quot;&quot;</span> &lt;&lt; filename &lt;&lt; <span class="string">&quot;\&quot;。\n&quot;</span>;</span><br><span class="line">      <span class="built_in">printUsage</span>(argv[<span class="number">0</span>]);</span><br><span class="line">      <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 根据点云自带的传感器位姿设置</span></span><br><span class="line">    scene_sensor_pose =</span><br><span class="line">        Eigen::<span class="built_in">Affine3f</span>(Eigen::<span class="built_in">Translation3f</span>(point_cloud.sensor_origin_[<span class="number">0</span>],</span><br><span class="line">                                               point_cloud.sensor_origin_[<span class="number">1</span>],</span><br><span class="line">                                               point_cloud.sensor_origin_[<span class="number">2</span>])) *</span><br><span class="line">        Eigen::<span class="built_in">Affine3f</span>(point_cloud.sensor_orientation_);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 尝试读取远距点云</span></span><br><span class="line">    std::string far_ranges_filename =</span><br><span class="line">        pcl::<span class="built_in">getFilenameWithoutExtension</span>(filename) + <span class="string">&quot;_far_ranges.pcd&quot;</span>;</span><br><span class="line">    <span class="keyword">if</span> (pcl::io::<span class="built_in">loadPCDFile</span>(far_ranges_filename.<span class="built_in">c_str</span>(), far_ranges) == <span class="number">-1</span>)</span><br><span class="line">      std::cout &lt;&lt; <span class="string">&quot;远距范围文件 \&quot;&quot;</span> &lt;&lt; far_ranges_filename &lt;&lt; <span class="string">&quot;\&quot; 不存在。\n&quot;</span>;</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">  &#123;</span><br><span class="line">    std::cout &lt;&lt; <span class="string">&quot;\n未给定 *.pcd 文件 =&gt; 生成示例点云。\n\n&quot;</span>;</span><br><span class="line">    <span class="comment">// 生成 100×100 的网格样例</span></span><br><span class="line">    <span class="keyword">for</span> (<span class="type">float</span> x = <span class="number">-0.5f</span>; x &lt;= <span class="number">0.5f</span>; x += <span class="number">0.01f</span>)</span><br><span class="line">    &#123;</span><br><span class="line">      <span class="keyword">for</span> (<span class="type">float</span> y = <span class="number">-0.5f</span>; y &lt;= <span class="number">0.5f</span>; y += <span class="number">0.01f</span>)</span><br><span class="line">      &#123;</span><br><span class="line">        PointType point;</span><br><span class="line">        point.x = x;</span><br><span class="line">        point.y = y;</span><br><span class="line">        point.z = <span class="number">2.0f</span> - y;</span><br><span class="line">        point_cloud.points.<span class="built_in">push_back</span>(point);</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    point_cloud.width  = <span class="built_in">static_cast</span>&lt;<span class="type">int</span>&gt;(point_cloud.points.<span class="built_in">size</span>());</span><br><span class="line">    point_cloud.height = <span class="number">1</span>;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// -----------------------------------------------</span></span><br><span class="line">  <span class="comment">// -----从点云创建深度图像-----</span></span><br><span class="line">  <span class="comment">// -----------------------------------------------</span></span><br><span class="line">  <span class="type">float</span> noise_level = <span class="number">0.0f</span>;</span><br><span class="line">  <span class="type">float</span> min_range   = <span class="number">0.0f</span>;</span><br><span class="line">  <span class="type">int</span> border_size   = <span class="number">1</span>;</span><br><span class="line"></span><br><span class="line">  <span class="function">boost::shared_ptr&lt;pcl::RangeImage&gt; <span class="title">range_image_ptr</span><span class="params">(<span class="keyword">new</span> pcl::RangeImage)</span></span>;</span><br><span class="line">  pcl::RangeImage&amp; range_image = *range_image_ptr;</span><br><span class="line"></span><br><span class="line">  range_image.<span class="built_in">createFromPointCloud</span>(</span><br><span class="line">      point_cloud, angular_resolution,</span><br><span class="line">      pcl::<span class="built_in">deg2rad</span>(<span class="number">360.0f</span>), pcl::<span class="built_in">deg2rad</span>(<span class="number">180.0f</span>),</span><br><span class="line">      scene_sensor_pose, coordinate_frame,</span><br><span class="line">      noise_level, min_range, border_size);</span><br><span class="line"></span><br><span class="line">  range_image.<span class="built_in">integrateFarRanges</span>(far_ranges);   <span class="comment">// 融合远距数据</span></span><br><span class="line">  <span class="keyword">if</span> (setUnseenToMaxRange)</span><br><span class="line">    range_image.<span class="built_in">setUnseenToMaxRange</span>();</span><br><span class="line"></span><br><span class="line">  <span class="comment">// --------------------------------------------</span></span><br><span class="line">  <span class="comment">// -----打开 3D 可视化器并添加点云-----</span></span><br><span class="line">  <span class="comment">// --------------------------------------------</span></span><br><span class="line">  pcl::<span class="function">visualization::PCLVisualizer <span class="title">viewer</span><span class="params">(<span class="string">&quot;3D 浏览器&quot;</span>)</span></span>;</span><br><span class="line">  viewer.<span class="built_in">setBackgroundColor</span>(<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>);   <span class="comment">// 白色背景</span></span><br><span class="line">  viewer.<span class="built_in">addCoordinateSystem</span>(<span class="number">1.0f</span>);     <span class="comment">// 坐标轴</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// 原始点云（黑色）</span></span><br><span class="line">  pcl::<span class="function">visualization::PointCloudColorHandlerCustom&lt;PointType&gt;</span></span><br><span class="line"><span class="function">      <span class="title">point_cloud_color_handler</span><span class="params">(point_cloud_ptr, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>)</span></span>;</span><br><span class="line">  viewer.<span class="built_in">addPointCloud</span>(point_cloud_ptr, point_cloud_color_handler,</span><br><span class="line">                       <span class="string">&quot;original point cloud&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// -------------------------</span></span><br><span class="line">  <span class="comment">// -----提取边界-----</span></span><br><span class="line">  <span class="comment">// -------------------------</span></span><br><span class="line">  <span class="function">pcl::RangeImageBorderExtractor <span class="title">border_extractor</span><span class="params">(&amp;range_image)</span></span>;</span><br><span class="line">  pcl::PointCloud&lt;pcl::BorderDescription&gt; border_descriptions;</span><br><span class="line">  border_extractor.<span class="built_in">compute</span>(border_descriptions);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// ----------------------------------</span></span><br><span class="line">  <span class="comment">// -----在 3D 浏览器中显示边界点-----</span></span><br><span class="line">  <span class="comment">// ----------------------------------</span></span><br><span class="line">  pcl::PointCloud&lt;pcl::PointWithRange&gt;::<span class="function">Ptr</span></span><br><span class="line"><span class="function">      <span class="title">border_points_ptr</span><span class="params">(<span class="keyword">new</span> pcl::PointCloud&lt;pcl::PointWithRange&gt;)</span>,</span></span><br><span class="line"><span class="function">      <span class="title">veil_points_ptr</span><span class="params">(<span class="keyword">new</span> pcl::PointCloud&lt;pcl::PointWithRange&gt;)</span>,</span></span><br><span class="line"><span class="function">      <span class="title">shadow_points_ptr</span><span class="params">(<span class="keyword">new</span> pcl::PointCloud&lt;pcl::PointWithRange&gt;)</span></span>;</span><br><span class="line">  <span class="keyword">auto</span>&amp; border_points = *border_points_ptr;</span><br><span class="line">  <span class="keyword">auto</span>&amp; veil_points   = *veil_points_ptr;</span><br><span class="line">  <span class="keyword">auto</span>&amp; shadow_points = *shadow_points_ptr;</span><br><span class="line"></span><br><span class="line">  <span class="keyword">for</span> (<span class="type">int</span> y = <span class="number">0</span>; y &lt; <span class="built_in">static_cast</span>&lt;<span class="type">int</span>&gt;(range_image.height); ++y)</span><br><span class="line">  &#123;</span><br><span class="line">    <span class="keyword">for</span> (<span class="type">int</span> x = <span class="number">0</span>; x &lt; <span class="built_in">static_cast</span>&lt;<span class="type">int</span>&gt;(range_image.width); ++x)</span><br><span class="line">    &#123;</span><br><span class="line">      <span class="type">size_t</span> idx = y * range_image.width + x;</span><br><span class="line">      <span class="keyword">if</span> (border_descriptions.points[idx].traits[pcl::BORDER_TRAIT__OBSTACLE_BORDER])</span><br><span class="line">        border_points.points.<span class="built_in">push_back</span>(range_image.points[idx]);</span><br><span class="line">      <span class="keyword">if</span> (border_descriptions.points[idx].traits[pcl::BORDER_TRAIT__VEIL_POINT])</span><br><span class="line">        veil_points.points.<span class="built_in">push_back</span>(range_image.points[idx]);</span><br><span class="line">      <span class="keyword">if</span> (border_descriptions.points[idx].traits[pcl::BORDER_TRAIT__SHADOW_BORDER])</span><br><span class="line">        shadow_points.points.<span class="built_in">push_back</span>(range_image.points[idx]);</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 障碍物边界（绿色）</span></span><br><span class="line">  pcl::<span class="function">visualization::PointCloudColorHandlerCustom&lt;pcl::PointWithRange&gt;</span></span><br><span class="line"><span class="function">      <span class="title">border_points_color_handler</span><span class="params">(border_points_ptr, <span class="number">0</span>, <span class="number">255</span>, <span class="number">0</span>)</span></span>;</span><br><span class="line">  viewer.<span class="built_in">addPointCloud</span>&lt;pcl::PointWithRange&gt;(border_points_ptr,</span><br><span class="line">                                            border_points_color_handler,</span><br><span class="line">                                            <span class="string">&quot;边界点&quot;</span>);</span><br><span class="line">  viewer.<span class="built_in">setPointCloudRenderingProperties</span>(</span><br><span class="line">      pcl::visualization::PCL_VISUALIZER_POINT_SIZE, <span class="number">7</span>, <span class="string">&quot;边界点&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 面纱点（红色）</span></span><br><span class="line">  pcl::<span class="function">visualization::PointCloudColorHandlerCustom&lt;pcl::PointWithRange&gt;</span></span><br><span class="line"><span class="function">      <span class="title">veil_points_color_handler</span><span class="params">(veil_points_ptr, <span class="number">255</span>, <span class="number">0</span>, <span class="number">0</span>)</span></span>;</span><br><span class="line">  viewer.<span class="built_in">addPointCloud</span>&lt;pcl::PointWithRange&gt;(veil_points_ptr,</span><br><span class="line">                                            veil_points_color_handler,</span><br><span class="line">                                            <span class="string">&quot;面纱点&quot;</span>);</span><br><span class="line">  viewer.<span class="built_in">setPointCloudRenderingProperties</span>(</span><br><span class="line">      pcl::visualization::PCL_VISUALIZER_POINT_SIZE, <span class="number">7</span>, <span class="string">&quot;面纱点&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 阴影边界（青色）</span></span><br><span class="line">  pcl::<span class="function">visualization::PointCloudColorHandlerCustom&lt;pcl::PointWithRange&gt;</span></span><br><span class="line"><span class="function">      <span class="title">shadow_points_color_handler</span><span class="params">(shadow_points_ptr, <span class="number">0</span>, <span class="number">255</span>, <span class="number">255</span>)</span></span>;</span><br><span class="line">  viewer.<span class="built_in">addPointCloud</span>&lt;pcl::PointWithRange&gt;(shadow_points_ptr,</span><br><span class="line">                                            shadow_points_color_handler,</span><br><span class="line">                                            <span class="string">&quot;阴影点&quot;</span>);</span><br><span class="line">  viewer.<span class="built_in">setPointCloudRenderingProperties</span>(</span><br><span class="line">      pcl::visualization::PCL_VISUALIZER_POINT_SIZE, <span class="number">7</span>, <span class="string">&quot;阴影点&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 在深度图像窗口中显示带边界的深度图</span></span><br><span class="line">  pcl::visualization::RangeImageVisualizer* range_image_borders_widget =</span><br><span class="line">      pcl::visualization::RangeImageVisualizer::<span class="built_in">getRangeImageBordersWidget</span>(</span><br><span class="line">          range_image,</span><br><span class="line">          -std::numeric_limits&lt;<span class="type">float</span>&gt;::<span class="built_in">infinity</span>(),</span><br><span class="line">          std::numeric_limits&lt;<span class="type">float</span>&gt;::<span class="built_in">infinity</span>(),</span><br><span class="line">          <span class="literal">false</span>,</span><br><span class="line">          border_descriptions,</span><br><span class="line">          <span class="string">&quot;带边界的深度图像&quot;</span>);</span><br><span class="line"></span><br><span class="line">  <span class="comment">// --------------------</span></span><br><span class="line">  <span class="comment">// -----主循环-----</span></span><br><span class="line">  <span class="comment">// --------------------</span></span><br><span class="line">  <span class="keyword">while</span> (!viewer.<span class="built_in">wasStopped</span>())</span><br><span class="line">  &#123;</span><br><span class="line">    range_image_borders_widget-&gt;<span class="built_in">spinOnce</span>();</span><br><span class="line">    viewer.<span class="built_in">spinOnce</span>();</span><br><span class="line">    <span class="built_in">pcl_sleep</span>(<span class="number">0.01</span>);</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="点云到深度图的变换与曲面重建"><a href="#点云到深度图的变换与曲面重建" class="headerlink" title="点云到深度图的变换与曲面重建"></a>点云到深度图的变换与曲面重建</h2><p><strong>运行时窗口名的中文部分会显示乱码</strong></p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/range_image/range_image.h&gt;</span>                <span class="comment">// 深度图像基础类</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/range_image/range_image_planar.h&gt;</span>         <span class="comment">// 平面深度图像类</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/io/io.h&gt;</span>                                  <span class="comment">// 通用IO</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/io/pcd_io.h&gt;</span>                              <span class="comment">// PCD文件读写</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/features/integral_image_normal.h&gt;</span>         <span class="comment">// 积分图法线估计</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/visualization/cloud_viewer.h&gt;</span>             <span class="comment">// 点云可视化</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/point_types.h&gt;</span>                            <span class="comment">// 点类型定义</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/features/normal_3d.h&gt;</span>                     <span class="comment">// 法线估计</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/console/print.h&gt;</span>                          <span class="comment">// 控制台打印</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/surface/organized_fast_mesh.h&gt;</span>            <span class="comment">// 快速网格化</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/console/time.h&gt;</span>                           <span class="comment">// 计时</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;Eigen/StdVector&gt;</span>                              <span class="comment">// Eigen 容器</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;Eigen/Geometry&gt;</span>                               <span class="comment">// Eigen 几何</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;iostream&gt;</span>                                     <span class="comment">// 标准输入输出</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/surface/impl/organized_fast_mesh.hpp&gt;</span>     <span class="comment">// 模板实现</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;boost/thread/thread.hpp&gt;</span>                      <span class="comment">// Boost 线程</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/common/common_headers.h&gt;</span>                  <span class="comment">// 公共头文件</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/visualization/range_image_visualizer.h&gt;</span>   <span class="comment">// 深度图像可视化</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/visualization/pcl_visualizer.h&gt;</span>           <span class="comment">// 3D 可视化</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;pcl/console/parse.h&gt;</span>                          <span class="comment">// 命令行解析</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> pcl::console;                           <span class="comment">// 使用 pcl::console 命名空间</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">(<span class="type">int</span> argc, <span class="type">char</span>** argv)</span> </span>&#123;</span><br><span class="line">    <span class="comment">// 如果参数不足，打印用法并退出</span></span><br><span class="line">    <span class="keyword">if</span> (argc &lt; <span class="number">2</span>) &#123;</span><br><span class="line">        <span class="built_in">print_error</span>(<span class="string">&quot;用法：%s input.pcd -w 640 -h 480 -cx 320 -cy 240 -fx 525 -fy 525 -type 0 -size 2\n&quot;</span>, argv[<span class="number">0</span>]);</span><br><span class="line">        <span class="built_in">print_info</span>(<span class="string">&quot;  参数说明：\n&quot;</span>);</span><br><span class="line">        <span class="built_in">print_info</span>(<span class="string">&quot;  -w X   深度图像宽度（像素）\n&quot;</span>);</span><br><span class="line">        <span class="built_in">print_info</span>(<span class="string">&quot;  -h X   深度图像高度（像素）\n&quot;</span>);</span><br><span class="line">        <span class="built_in">print_info</span>(<span class="string">&quot;  -cx X  光心x坐标（像素）\n&quot;</span>);</span><br><span class="line">        <span class="built_in">print_info</span>(<span class="string">&quot;  -cy X  光心y坐标（像素）\n&quot;</span>);</span><br><span class="line">        <span class="built_in">print_info</span>(<span class="string">&quot;  -fx X  焦距x（像素）\n&quot;</span>);</span><br><span class="line">        <span class="built_in">print_info</span>(<span class="string">&quot;  -fy X  焦距y（像素）\n&quot;</span>);</span><br><span class="line">        <span class="built_in">print_info</span>(<span class="string">&quot;  -type X  三角剖分类型（0-3）\n&quot;</span>);</span><br><span class="line">        <span class="built_in">print_info</span>(<span class="string">&quot;  -size X  三角形像素大小\n&quot;</span>);</span><br><span class="line">        <span class="keyword">return</span> <span class="number">-1</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 获取文件名</span></span><br><span class="line">    std::string filename = argv[<span class="number">1</span>];</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 默认参数</span></span><br><span class="line">    <span class="type">int</span> width = <span class="number">640</span>, height = <span class="number">480</span>, size = <span class="number">2</span>, type = <span class="number">0</span>;</span><br><span class="line">    <span class="type">float</span> fx = <span class="number">525</span>, fy = <span class="number">525</span>, cx = <span class="number">320</span>, cy = <span class="number">240</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 解析命令行参数</span></span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-w&quot;</span>, width);</span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-h&quot;</span>, height);</span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-cx&quot;</span>, cx);</span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-cy&quot;</span>, cy);</span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-fx&quot;</span>, fx);</span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-fy&quot;</span>, fy);</span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-type&quot;</span>, type);</span><br><span class="line">    <span class="built_in">parse_argument</span>(argc, argv, <span class="string">&quot;-size&quot;</span>, size);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 读取点云文件</span></span><br><span class="line">    pcl::PointCloud&lt;pcl::PointXYZRGB&gt;::<span class="function">Ptr <span class="title">cloud</span><span class="params">(<span class="keyword">new</span> pcl::PointCloud&lt;pcl::PointXYZRGB&gt;)</span></span>;</span><br><span class="line">    pcl::io::<span class="built_in">loadPCDFile</span>(filename, *cloud);</span><br><span class="line">    <span class="built_in">print_info</span>(<span class="string">&quot;成功读取 PCD 文件\n&quot;</span>); </span><br><span class="line"></span><br><span class="line">    <span class="comment">// 设置传感器位姿（单位矩阵）</span></span><br><span class="line">    Eigen::Affine3f sensorPose = Eigen::Affine3f::<span class="built_in">Identity</span>();</span><br><span class="line">    pcl::RangeImage::CoordinateFrame coordinate_frame = pcl::RangeImage::CAMERA_FRAME;</span><br><span class="line">    <span class="type">float</span> noiseLevel = <span class="number">0.00f</span>;</span><br><span class="line">    <span class="type">float</span> minRange = <span class="number">0.0f</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 将无序点云转换为有序深度图像</span></span><br><span class="line">    pcl::<span class="function">RangeImagePlanar::Ptr <span class="title">rangeImage</span><span class="params">(<span class="keyword">new</span> pcl::RangeImagePlanar)</span></span>;</span><br><span class="line">    rangeImage-&gt;<span class="built_in">createFromPointCloudWithFixedSize</span>(</span><br><span class="line">        *cloud, width, height, cx, cy, fx, fy, sensorPose, coordinate_frame);</span><br><span class="line">    std::cout &lt;&lt; <span class="string">&quot;生成的深度图像信息：\n&quot;</span> &lt;&lt; *rangeImage &lt;&lt; <span class="string">&quot;\n&quot;</span>; </span><br><span class="line"></span><br><span class="line">    <span class="comment">// 可视化深度图像</span></span><br><span class="line">    pcl::<span class="function">visualization::RangeImageVisualizer <span class="title">range_image_widget</span><span class="params">(<span class="string">&quot;深度图像&quot;</span>)</span></span>;</span><br><span class="line">    range_image_widget.<span class="built_in">showRangeImage</span>(*rangeImage);</span><br><span class="line">    range_image_widget.<span class="built_in">setWindowTitle</span>(<span class="string">&quot;深度图像&quot;</span>);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 基于深度图像进行三角剖分</span></span><br><span class="line">    pcl::OrganizedFastMesh&lt;pcl::PointWithRange&gt;::<span class="function">Ptr <span class="title">tri</span><span class="params">(<span class="keyword">new</span> pcl::OrganizedFastMesh&lt;pcl::PointWithRange&gt;)</span></span>;</span><br><span class="line">    pcl::search::KdTree&lt;pcl::PointWithRange&gt;::<span class="function">Ptr <span class="title">tree</span><span class="params">(<span class="keyword">new</span> pcl::search::KdTree&lt;pcl::PointWithRange&gt;)</span></span>;</span><br><span class="line">    tree-&gt;<span class="built_in">setInputCloud</span>(rangeImage);</span><br><span class="line"></span><br><span class="line">    pcl::PolygonMesh triangles;</span><br><span class="line">    tri-&gt;<span class="built_in">setTrianglePixelSize</span>(size);  <span class="comment">// 三角形像素大小</span></span><br><span class="line">    tri-&gt;<span class="built_in">setInputCloud</span>(rangeImage);</span><br><span class="line">    tri-&gt;<span class="built_in">setSearchMethod</span>(tree);</span><br><span class="line">    tri-&gt;<span class="built_in">setTriangulationType</span>(<span class="keyword">static_cast</span>&lt;pcl::OrganizedFastMesh&lt;pcl::PointWithRange&gt;::TriangulationType&gt;(type));</span><br><span class="line">    tri-&gt;<span class="built_in">reconstruct</span>(triangles);</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 3D 可视化网格</span></span><br><span class="line">    <span class="function">boost::shared_ptr&lt;pcl::visualization::PCLVisualizer&gt; <span class="title">viewer</span><span class="params">(</span></span></span><br><span class="line"><span class="params"><span class="function">        <span class="keyword">new</span> pcl::visualization::PCLVisualizer(<span class="string">&quot;三角网格可视化&quot;</span>))</span></span>;</span><br><span class="line">    viewer-&gt;<span class="built_in">setBackgroundColor</span>(<span class="number">0.5</span>, <span class="number">0.5</span>, <span class="number">0.5</span>);  <span class="comment">// 灰色背景</span></span><br><span class="line">    viewer-&gt;<span class="built_in">addPolygonMesh</span>(triangles, <span class="string">&quot;tin&quot;</span>);     <span class="comment">// 添加网格</span></span><br><span class="line">    viewer-&gt;<span class="built_in">addCoordinateSystem</span>();                <span class="comment">// 坐标轴</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 主循环：等待窗口关闭</span></span><br><span class="line">    <span class="keyword">while</span> (!range_image_widget.<span class="built_in">wasStopped</span>() &amp;&amp; !viewer-&gt;<span class="built_in">wasStopped</span>()) &#123;</span><br><span class="line">        range_image_widget.<span class="built_in">spinOnce</span>();</span><br><span class="line">        <span class="built_in">pcl_sleep</span>(<span class="number">0.01</span>);</span><br><span class="line">        viewer-&gt;<span class="built_in">spinOnce</span>();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://ckyfi9zero.github.io">Fi9zero</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://ckyfi9zero.github.io/2025/08/02/2025-08-02-PCL%E4%B8%AD%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F%E7%9B%B8%E5%85%B3%E7%AE%97%E6%B3%95/">https://ckyfi9zero.github.io/2025/08/02/2025-08-02-PCL%E4%B8%AD%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F%E7%9B%B8%E5%85%B3%E7%AE%97%E6%B3%95/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来源 <a href="https://ckyfi9zero.github.io" target="_blank">荒岛</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/c/">c++</a><a class="post-meta__tags" href="/tags/PCL/">PCL</a></div><div class="post-share"><div class="social-share" data-image="/image/avatar.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><a class="pagination-related  no-desc" href="/2025/08/02/2025-08-02-%E5%85%B3%E9%94%AE%E7%82%B9/" title="关键点"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info"><div class="info-1"><div class="info-item-1">上一篇</div><div class="info-item-2">关键点</div></div></div></a><a class="pagination-related  no-desc" href="/2025/08/01/2025-08-01-%E4%BB%8E%E7%82%B9%E4%BA%91%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F/" title="从点云创建一个深度图像"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-right"><div class="info-1"><div class="info-item-1">下一篇</div><div class="info-item-2">从点云创建一个深度图像</div></div></div></a></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E7%94%A8kdtree%E5%AE%9E%E7%8E%B0%E5%BF%AB%E9%80%9F%E9%A2%86%E5%9F%9F%E6%90%9C%E7%B4%A2/" title="用kdtree实现快速领域搜索"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">用kdtree实现快速领域搜索</div></div></div></a><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E7%94%A8%E5%85%AB%E5%8F%89%E6%A0%91%E8%BF%9B%E8%A1%8C%E6%97%A0%E5%BA%8F%E7%82%B9%E4%BA%91%E6%95%B0%E6%8D%AE%E7%9A%84%E7%A9%BA%E9%97%B4%E5%8F%98%E5%8C%96%E6%A3%80%E6%B5%8B/" title="用八叉树进行无序点云数据的空间变化检测"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">用八叉树进行无序点云数据的空间变化检测</div></div></div></a><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E7%94%A8%E7%9B%B4%E9%80%9A%E6%BB%A4%E6%B3%A2%E5%99%A8%E5%AF%B9%E7%82%B9%E4%BA%91%E8%BF%9B%E8%A1%8C%E6%BB%A4%E6%B3%A2%E5%A4%84%E7%90%86/" title="用直通滤波器对点云进行滤波处理"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">用直通滤波器对点云进行滤波处理</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/01/2025-08-01-%E4%BB%8E%E7%82%B9%E4%BA%91%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F/" title="从点云创建一个深度图像"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-01</div><div class="info-item-2">从点云创建一个深度图像</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/01/2025-08-01-%E4%BB%8E%E4%B8%80%E4%B8%AA%E7%82%B9%E4%BA%91%E4%B8%AD%E6%8F%90%E5%8F%96%E4%B8%80%E4%B8%AA%E5%AD%90%E9%9B%86/" title="从一个点云中提取一个子集"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-01</div><div class="info-item-2">从一个点云中提取一个子集</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/01/2025-08-01-%E5%9C%A8%E6%BB%A4%E6%B3%A2%E5%99%A8%E6%A8%A1%E5%9D%97%E7%A7%BB%E9%99%A4%E7%A6%BB%E7%BE%A4%E7%82%B9/" title="在滤波器模块移除离群点"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-01</div><div class="info-item-2">在滤波器模块移除离群点</div></div></div></a></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info text-center"><div class="avatar-img"><img src="/image/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info-name">Fi9zero</div><div class="author-info-description"></div><div class="site-data"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/ckyFi9zero"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons"><a class="social-icon" href="https://github.com/ckyFi9zero" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:2539894206@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F"><span class="toc-number">1.</span> <span class="toc-text">深度图像</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%8E%E4%B8%80%E4%B8%AA%E7%82%B9%E4%BA%91%E7%94%9F%E6%88%90%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F"><span class="toc-number">1.1.</span> <span class="toc-text">从一个点云生成深度图像</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BB%8E%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F%E4%B8%AD%E6%8F%90%E5%8F%96%E8%BE%B9%E7%95%8C"><span class="toc-number">1.2.</span> <span class="toc-text">从深度图像中提取边界</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%82%B9%E4%BA%91%E5%88%B0%E6%B7%B1%E5%BA%A6%E5%9B%BE%E7%9A%84%E5%8F%98%E6%8D%A2%E4%B8%8E%E6%9B%B2%E9%9D%A2%E9%87%8D%E5%BB%BA"><span class="toc-number">1.3.</span> <span class="toc-text">点云到深度图的变换与曲面重建</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/10/05/2025-10-05-lio_sam/" title="lio_sam">lio_sam</a><time datetime="2025-10-05T02:43:51.000Z" title="发表于 2025-10-05 10:43:51">2025-10-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/12/2025-08-12-%E4%BD%BF%E7%94%A8docker%E6%90%AD%E5%BB%BApytorch%E7%8E%AF%E5%A2%83/" title="使用docker搭建pytorch环境">使用docker搭建pytorch环境</a><time datetime="2025-08-12T12:43:33.000Z" title="发表于 2025-08-12 20:43:33">2025-08-12</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-docker/" title="docker">docker</a><time datetime="2025-08-05T11:02:36.000Z" title="发表于 2025-08-05 19:02:36">2025-08-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-%E8%BF%90%E5%8A%A8%E5%AF%B9%E8%B1%A1%E5%88%86%E5%89%B2%E4%B8%8E%E9%85%8D%E5%87%86%E7%AE%97%E6%B3%95/" title="运动对象分割与配准算法">运动对象分割与配准算法</a><time datetime="2025-08-05T08:16:02.000Z" title="发表于 2025-08-05 16:16:02">2025-08-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-%E6%9D%A1%E4%BB%B6%E6%AC%A7%E5%BC%8F%E8%81%9A%E7%B1%BB%E5%88%86%E5%89%B2/" title="条件欧式聚类分割">条件欧式聚类分割</a><time datetime="2025-08-05T07:56:39.000Z" title="发表于 2025-08-05 15:56:39">2025-08-05</time></div></div></div></div></div></div></main><footer id="footer"><div class="footer-other"><div class="footer-copyright"><span class="copyright">&copy;&nbsp;2025 By Fi9zero</span><span class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo 7.3.0</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly 5.4.2</a></span></div><div class="footer_custom_text">Only light can attract bugs.</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="日间和夜间模式切换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><div class="js-pjax"><script>(() => {
  const loadMathjax = () => {
    if (!window.MathJax) {
      window.MathJax = {
        tex: {
          inlineMath: [['$', '$'], ['\\(', '\\)']],
          tags: 'none',
        },
        chtml: {
          scale: 1.1
        },
        options: {
          enableMenu: true,
          renderActions: {
            findScript: [10, doc => {
              for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
                const display = !!node.type.match(/; *mode=display/)
                const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
                const text = document.createTextNode('')
                node.parentNode.replaceChild(text, node)
                math.start = {node: text, delim: '', n: 0}
                math.end = {node: text, delim: '', n: 0}
                doc.math.push(math)
              }
            }, '']
          }
        }
      }

      const script = document.createElement('script')
      script.src = 'https://cdn.jsdelivr.net/npm/mathjax/es5/tex-mml-chtml.min.js'
      script.id = 'MathJax-script'
      script.async = true
      document.head.appendChild(script)
    } else {
      MathJax.startup.document.state(0)
      MathJax.texReset()
      MathJax.typesetPromise()
    }
  }

  btf.addGlobalFn('encrypt', loadMathjax, 'mathjax')
  window.pjax ? loadMathjax() : window.addEventListener('load', loadMathjax)
})()</script><script>(() => {
  const runMermaid = ele => {
    window.loadMermaid = true
    const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'default'

    ele.forEach((item, index) => {
      const mermaidSrc = item.firstElementChild
      const mermaidThemeConfig = `%%{init:{ 'theme':'${theme}'}}%%\n`
      const mermaidID = `mermaid-${index}`
      const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent

      const renderFn = mermaid.render(mermaidID, mermaidDefinition)
      const renderMermaid = svg => {
        mermaidSrc.insertAdjacentHTML('afterend', svg)
      }

      // mermaid v9 and v10 compatibility
      typeof renderFn === 'string' ? renderMermaid(renderFn) : renderFn.then(({ svg }) => renderMermaid(svg))
    })
  }

  const codeToMermaid = () => {
    const codeMermaidEle = document.querySelectorAll('pre > code.mermaid')
    if (codeMermaidEle.length === 0) return

    codeMermaidEle.forEach(ele => {
      const preEle = document.createElement('pre')
      preEle.className = 'mermaid-src'
      preEle.hidden = true
      preEle.textContent = ele.textContent
      const newEle = document.createElement('div')
      newEle.className = 'mermaid-wrap'
      newEle.appendChild(preEle)
      ele.parentNode.replaceWith(newEle)
    })
  }

  const loadMermaid = () => {
    if (true) codeToMermaid()
    const $mermaid = document.querySelectorAll('#article-container .mermaid-wrap')
    if ($mermaid.length === 0) return

    const runMermaidFn = () => runMermaid($mermaid)
    btf.addGlobalFn('themeChange', runMermaidFn, 'mermaid')
    window.loadMermaid ? runMermaidFn() : btf.getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaidFn)
  }

  btf.addGlobalFn('encrypt', loadMermaid, 'mermaid')
  window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
})()</script></div><script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script defer data-pjax src="/js/pig.js"></script><script src="/js/weather.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="text-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="站内搜索..." type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>